package trace.config;

import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

import java.io.Serializable;

/**
 * @Author: lgp
 * @Date: 2021/8/12 16:05
 * @Description:
 */
public class SparkSaConfig implements Serializable {
    public String name,localdir,hdfsinput,hdfsoutput,hdfsHost,hdfsUser,hdfsHostOr,hdfsN3DNS,hdfsN3GAME,hdfsN3HTTP,hdfsN3IM,hdfsN3OTHERS,hdfsN3STREAMING;

    public SparkSaConfig(String cfgname) throws DocumentException {
        SAXReader reader = new SAXReader();
        Element root = reader.read(SparkConfig.class.getResourceAsStream("/"+cfgname)).getRootElement();
        name = root.attributeValue("name");
        localdir = root.elementText("localdir");
        hdfsinput = root.elementText("hdfsinput");
        hdfsN3DNS = root.elementText("hdfsN3DNS");
        hdfsN3GAME = root.elementText("hdfsN3GAME");
        hdfsN3HTTP = root.elementText("hdfsN3HTTP");
        hdfsN3IM = root.elementText("hdfsN3IM");
        hdfsN3OTHERS = root.elementText("hdfsN3OTHERS");
        hdfsN3STREAMING = root.elementText("hdfsN3STREAMING");
        hdfsoutput = root.elementText("hdfsoutput");
        hdfsHost = root.elementText("hdfsHost");
        hdfsUser = root.elementText("hdfsUser");
        hdfsHostOr = root.elementText("hdfsHostOr");
    }
}
